<template>
	<view class="main_box">
		<view class="fix_title">
			绑定用户信息
		</view>
		<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y">
			<view class="card" v-for="(item,index) in stuList" :key="index" :id="'dem0'+index">
				<view class="kpl">
					<text>学校:</text>
					<text>{{item.empData.orgName}}</text>
				</view>
				<view class="kpl">
					<text>姓名:</text>
					<text>{{item.empData.empName}}</text>
				</view>
				<view class="kpl">
					<text>学号:</text>
					<text>{{item.empData.empNo}}</text>
				</view>
				<view class="lsp">
					<text></text>
					<text @click="toPutBind(item)">解绑</text>
				</view>
			</view>
		</scroll-view>
		<view class="kdn">
			<image src="/static/images/blank/4341yu.png" mode=""></image>
			<view class="subx">
				交通银行 提供产品服务
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPhoneCode,
		getTwoUserList,
		getMoneny,
		bindTwoEmpStu,
		TwoUserBindStuList,
		TwoUserDeleteStu
	} from '../../common/api/blank.js';
	import {
		queryOrg,
		findBaseArea,
		queryMilkCardBalance,
		queryStudentCardBalance,
		selectCardInfoByIdCardNo,
		openStudentMike
	} from '../../common/api/index.js'
	import {
		_showLoading,
		_showToast
	} from '../../common/js/util.js'
	export default {
		data() {
			return {
				stuList: [],
				scrollTop: 0,
				old: {
					scrollTop: 0
				}
			}
		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false
			}
			this.back();
			return true
		},
		async onLoad(option) {
			var s_userId = uni.getStorageSync("s_userId")
			uni.showLoading({
				title: "获取该卡号绑定用户信息"
			})
			try {
				const res = await TwoUserBindStuList({
					batId: option.batId
				})
				console.log(res)
				if (res.code == 0) {
					uni.hideLoading()
					if (res.data.length == 0) {
						this.stuList = []
						_showToast("该卡未绑定用户")
					} else {

						this.stuList = res.data
					}
					console.log(this.stuList)
				} else {
					uni.hideLoading()
					_showToast(res.msg)
				}
			} catch (err) {
				uni.hideLoading()
				_showToast(err)
			}

		},
		components: {

		},
		methods: {
			async toPutBind(item) {
				uni.showLoading({
					title: "解绑中"
				})
				try {
					const res = await TwoUserDeleteStu({
						"id": item.id,
						"orgId": item.orgId
					})
					if (res.code == 0) {
						this.stuList = this.stuList.filter(items => items != item)
						uni.hideLoading()
						_showToast("解绑成功")
					} else {
						uni.hideLoading()
						_showToast(res.msg)
					}
				} catch (err) {
					uni.hideLoading()
					_showToast(err)
				}
			},
			back() {
				var pages = getCurrentPages();
				uni.navigateBack({
					delta: pages.length - 2
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main_box {
		padding: 24upx;
		box-sizing: border-box;
		overflow-y: auto;

		.scroll-Y {
			max-height: 900rpx;
			height: auto;
		}

		.kdn {
			position: fixed;
			left: 0rpx;
			bottom: 68rpx;
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			>image {
				width: 34rpx;
				height: 33rpx;
			}

			.subx {
				margin-left: 8rpx;
				height: 34rpx;
				font-size: 23rpx;
				font-family: Source Han Sans CN-Regular, Source Han Sans CN;
				font-weight: 400;
				color: #003A79;
				line-height: 34rpx;
			}
		}

		.add {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin: 0 auto;
			margin-bottom: 493rpx;
			width: 690rpx;
			height: 102rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 26rpx 1rpx rgba(0, 0, 0, 0.06);
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			opacity: 1;

			.ans {
				height: 46rpx;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #40424E;
				line-height: 46rpx;
				margin-left: 32rpx;
			}

			.btns {
				width: 154rpx;
				height: 54rpx;
				line-height: 54rpx;
				text-align: center;
				background: #2D57F6;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				opacity: 1;
				font-size: 24rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 300;
				color: #FFFFFF;
				margin-right: 34rpx;
			}
		}

		.card {
			width: 690rpx;
			height: 244rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 26rpx 1rpx rgba(0, 0, 0, 0.06);
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			opacity: 1;
			margin: 0 auto;
			box-sizing: border-box;
			padding: 28rpx;
			margin-bottom: 32rpx;
			display: flex;
			flex-direction: column;
			// justify-content: space-between;

			.kpl {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;
				font-size: 26rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 500;
			}

			.lsp {
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;
				font-size: 26rpx;
				font-family: Source Han Sans CN-Light, Source Han Sans CN;
				font-weight: 500;
				color: #3F9BFB;
			}

		}

		.fix_title {
			margin: 30upx 0 60upx 0;
			font-size: 40upx;
			font-weight: bolder;
			display: flex;
			align-items: center;
			margin-left: 10rpx;

			&::before {
				content: '';
				height: 36upx;
				width: 12upx;
				background-image: linear-gradient(to bottom, #c3defc, #007AFF);
				margin-right: 12upx;
				border-radius: 6upx;
			}
		}
	}
</style>
